<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

// 网站首页入口
Route::get('/', 'home\HomeController@create');

// 登录首页
Route::get('/login', function(){
	return view('admin.login');
});

// 执行登录
Route::post('/dologin', 'admin\loginController@index');
// 验证码路由
Route::get('/yzm/{tmp}', 'admin\loginController@yzm');

// 注册路由
Route::post('/register', 'admin\loginController@register');
//前台注册路由
Route::get('/register', 'home\LoginController@register');
//前台执行注册
Route::post('/doregister','home\LoginController@doLogin');
//前台执行登录
Route::get('/doLogin','home\LoginController@index');
Route::post('/doLogin','home\LoginController@logging');
//前台登录退出
Route::get('/logOut','home\LoginController@logOut');

// 后台管理员路由组
Route::group(['prefix' => 'admin', 'middleware' => ['login']],function(){
		Route::get('manager/maid',function(){
			return view('admin.index');
		});

		Route::resource('manager/details', 'admin\managerController');

		Route::get('/outlogin', 'admin\loginController@outlogin');

		Route::get('users/maid',function(){
			return view('admin.index');
		});

		Route::resource('users/details', 'admin\usersController');
});

// 后台配置路由
Route::resource('admin/configure/details', 'admin\configureController');

// Route::get('ajax/get','admin\GoodsController@doget');
// Route::get('ajax/post','admin\GoodsController@dopost');

//后台路由组
Route::group(['prefix' => 'admin', 'middleware' => ['login']],function(){
		Route::get('/main',function(){
			return view('admin.index');
		});
		//商品控制器路由
		Route::resource('/goods','admin\GoodsController');
		Route::get('/ajax/get','admin\GoodsController@doget');
		Route::get('/ajax/post','admin\GoodsController@dopost');
		//类别管理
		Route::resource('/type','admin\TypeController');
		Route::get('/typeSon/{id}','admin\TypeController@createSon');
		Route::post('/typeSon','admin\TypeController@storeSon');
		//公告管理
		Route::resource('/notice','admin\NoticeController');
		//评价管理
		Route::resource('/comment','admin\CommentController');
		// 轮播图管理
		Route::resource('/album','admin\AlbumController');
		// 意见反馈管理
		Route::resource('/message','admin\MessageController');
		// 友情链接管理
		Route::resource('/flink','admin\FlinkController');
		// 订单管理
		Route::resource('/order','admin\OrderController');
		// 限时秒杀
		Route::resource('/flash','admin\FlashController');
});

// 前台路由群组
Route::group(['prefix' => 'home'],function(){
		// 前台显示页面
		// Route::resource('/homePage','home\HomeController');
		Route::get('/homePage','home\HomeController@create');
		// 商品列表页
		Route::get('/search/{id}','home\SearchController@index');
		// 查询分类下的商品
		Route::get('/next/{id}','home\SearchController@create');

		// 商品详情页
		Route::get('/introduction/{id}', 'home\introductionController@show');
});

// 个人中心路由组
Route::group(['prefix' => 'home', 'middleware' => ['homeLogin']],function(){
		// 个人中心模板
		Route::get('/base/person', function(){
			return view('home.base.person');
		});


		// 我的收藏
		Route::get('person/collection', 'home\collectionController@index');
		Route::get('/collect/{id}', 'home\collectionController@collect');
		// 取消收藏
		Route::get('/unCollection/{id}', 'home\collectionController@unCollection');


		// 个人中心的个人信息
		Route::get('/person/information', 'home\InformationController@index');
		Route::post('/person/information', 'home\InformationController@update');
		// 个人中心的密码修改
		Route::get('/person/password', 'home\PasswordController@index');
		Route::post('/person/password', 'home\PasswordController@update');
		Route::post('/person/userpwd', 'home\PasswordController@userpwd');

		// 个人中心路由
		Route::get('/person/index',function(){
			return view('home.person.index');
		});

		// 用户意见反馈路由
		Route::resource('/person/suggest', 'home\suggestController');

		// 购物车路由
		Route::get('/cart', 'home\shopcartController@cart');
		Route::get('/shopcart/{pid}', 'home\shopcartController@index');		
		
		// 立即购买
		Route::get('/payc/{pid}', 'home\payController@indexc');
		Route::get('/pay/{pid}', 'home\payController@index');		

		// 结算成功页面\
		Route::get('/dosuccess', 'home\doSuccessController@index');
		Route::get('/dosuccessb', 'home\doSuccessbController@index');
		Route::resource('/doPay', 'home\successController');			

		// 收藏页面
		Route::get('/collection', function(){
			return view('home.collection');
		});

		// 商品咨询路由
		Route::get('/person/consultation', function(){
			return view('home.person.consultation');
		});

		// 优惠卷路由
		Route::get('/coupon', function(){
			return view('home.person.coupon');
		});

		// 积分路由
		Route::get('/pointnew', function(){
			return view('home.person.pointnew');
		});

		// 积分明细路由
		Route::get('/points', function(){
			return view('home.person.points');
		});
		//我的地址路由
		Route::resource('/address','home\AddressController');
		Route::get('/ajax/get','home\AddressController@doget');
		Route::post('/ajax/post','home\AddressController@dopost');
		//一键支付的路由
		Route::get('/order/dopay/{id}','home\OrderController@dopay');
		//我的订单管理
		Route::resource('/order','home\OrderController');
		//订单评价
		Route::resource('/comment','home\CommentController');
		
});